﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DB_NH.DB_Map.ywxt
{
    using NHibernate;
    using NHibernate.Mapping.ByCode;
    using NHibernate.Mapping.ByCode.Conformist;

    using DB_NH.DB_Model.ywxt;

    class t_sys_department_Map : ClassMapping<t_sys_department>
    {
        public t_sys_department_Map()
        {
            //映射ID
            Id(x => x.dept_id, map => map.Length(40));

            Property(x => x.is_valid);
            Property(x => x.create_date);

            Property(x => x.dept_code, map => map.Length(20));
            Property(x => x.dept_email, map => map.Length(200));
            Property(x => x.dept_fax, map => map.Length(20));
            Property(x => x.dept_linker, map => map.Length(20));
            Property(x => x.dept_name, map => map.Length(20));
            Property(x => x.dept_phone, map => map.Length(20));
            Property(x => x.dept_level);
            Property(x => x.is_leaf);

            //关联部门用户
            Bag(x => x.users, map => map.Key(km => km.Column(t_sys_user.Columns.dept_id)), act => act.OneToMany());

            Table(t_sys_department.TableName);

            //不进行创建
            SchemaAction(NHibernate.Mapping.ByCode.SchemaAction.None);
        }
    }
}
